package com.hd.swagger0411.entity.utils;

import com.hd.swagger0411.entity.User;

/*
* 建造者模式 案例
* 通过UserBuilder创建一个User对象
* 要求:实现链接调用编码风格
* Integer id;
   String name;
   String password;
   String sex;
   Date birthday;
   Date registTime;*/
public class UserBuilder {
    private User user;
    public UserBuilder(){
        this.user=new User();
    }
    public UserBuilder withId(Integer id){
        this.user.setId(id);
        return this;
    }
    public UserBuilder withName(String name){
        this.user.setName(name);
        return this;
    }
    public UserBuilder withPassword(String password){
        this.user.setPassword(password);
        return this;
    }
    public User build() {
        return user;
    }

    public static void main(String[] args) {
        UserBuilder userBuilder = new UserBuilder();
        User lisi = userBuilder.withId(100).withName("lisi").build() ;
        System. out. println(lisi);

    }
}
